// 搜索信息渲染列表
export const userListApi = () => {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest()
        xhr.open('GET', 'http://127.0.0.1:3002/orders/getAllorders', true)
        xhr.send()
        xhr.onreadystatechange = () => {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    resolve(JSON.parse(xhr.responseText))
                }
            }
        }
    })
}
// 按照名字搜索客户信息
export const searListApi = (ordersname) => {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest()
        xhr.open('GET', `http://127.0.0.1:3002/orders/searchOrders?ordersName=${ordersname}`, true)
        xhr.send()
        xhr.onreadystatechange = () => {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    resolve(JSON.parse(xhr.responseText))
                }
            }
        }
    })
}
// 按照id搜索客户
export const byidListApi = (id) => {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest()
        xhr.open('GET', `http://127.0.0.1:3002/orders/byid/${id}`, true)
        xhr.send()
        xhr.onreadystatechange = () => {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    resolve(JSON.parse(xhr.responseText))
                }
            }
        }
    })
}
// 增加订单
export const addordersApi = (ordrswarranty) => {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest()
        xhr.open('POST', `http://127.0.0.1:3002/orders/addorders`, true)
        xhr.setRequestHeader('Content-Type', "application/json")
        xhr.send(ordrswarranty)
        xhr.onreadystatechange = () => {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    resolve(JSON.parse(xhr.responseText))
                    console.log('ab', JSON.parse(xhr.responseText));
                }
            }
        }
    })
}